<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:t="http://myfaces.apache.org/tomahawk"> 
    <ui:composition template="./WEB-INF/Templates/templateProjeto.xhtml">
        <ui:define name="titulo">Consulta Grupo Familiar</ui:define>
        <ui:define name="javascript">

            function controlaRadio(){
                var campo1 = document.getElementById("form:codFam");
                var campo2 = document.getElementById("form:codApf");
                var campo3 = document.getElementById("form:numLote");
                var campo4 = document.getElementById("form:numRem");
                var campo5 = document.getElementById("form:ordAtend");
                var campo6 = document.getElementById("form:nisRespFam");
 

                if(document.getElementById("form:radio0").checked){
                    campo1.disabled=false;
                    campo2.disabled=true;
                    campo3.disabled=true;
                    campo4.disabled=true;
                    campo5.disabled=true;
                    campo6.disabled=true;
                 }
                 if(document.getElementById("form:radio1").checked){
                    campo1.disabled=true;
                    campo2.disabled=false;
                    campo3.disabled=false;
                    campo4.disabled=false;
                    campo5.disabled=false;
                    campo6.disabled=false;
                 }
            }
            
            
            function disable(){
                document.getElementById("form:codFam").disabled=true;
                document.getElementById("form:codApf").disabled=true;
                document.getElementById("form:numLote").disabled=true;
                document.getElementById("form:numRem").disabled=true;
                document.getElementById("form:ordAtend").disabled=true;
                document.getElementById("form:nisRespFam").disabled=true;
            }

        </ui:define>
        <ui:define name="tituloH1">Consulta Grupo Familiar</ui:define>
        <ui:define name="pagLinda">
            <h1>Selecione os filtros para sua pesquisa</h1>
            <h:messages layout="list" style="color: darkred"/>
            <h:form id="form">
                <br/>
                
                <h:panelGrid columns="2" id="painel">
                    <h:panelGroup>
                        <t:selectOneRadio id="filtro" layout="spread" value="#{managedGrupoFam.numRadioPesquisa}" onchange="controlaRadio()">
                                <f:selectItem itemLabel="Por Codigo Familiar" itemValue="cod" />
                                <f:selectItem itemLabel="Usar filtros" itemValue="filtro"/>
                        </t:selectOneRadio>
                        <t:radio for="filtro" index="0" id="radio0" />
                    </h:panelGroup>
                    <h:inputHidden/>
                    
                    <b>Código Familiar</b>
                    <h:inputText id="codFam" value="#{managedGrupoFam.grupoFamiliar.codFamiliar}" label="Cod. Familiar">
                        <f:validateLength maximum="13"/>
                        <f:validateLongRange minimum="0"/>
                    </h:inputText>
                    
                    <br/>
                    <h:inputHidden/>
                    <t:radio for="filtro" index="1" id="radio1"/>
                    <h:inputHidden/>
                    
                    <b>Codigo APF do empreendimento</b>
                    <h:inputText id="codApf" value="#{managedGrupoFam.grupoFamiliar.emp.codigoComDigito}" label="Cod. APF">
                        <f:validator validatorId="validatorApf"/>
                    </h:inputText>

                    <b>Número do lote</b>
                    <h:inputText id="numLote" value="#{managedGrupoFam.grupoFamiliar.insc.loteRemessa.numeroLote}" label="Num. do lote">
                        <f:validateLongRange minimum="0"/>
                    </h:inputText>

                    <b>Número da remessa</b>
                    <h:inputText id="numRem" value="#{managedGrupoFam.grupoFamiliar.insc.loteRemessa.numeroRemessa}" label="Num. da Remessa">
                        <f:validateLongRange minimum="0" />
                    </h:inputText>

                    <b>Ordem de Atendimento</b>
                    <h:inputText id="ordAtend" value="#{managedGrupoFam.grupoFamiliar.insc.ordemAtendimento}" label="Ordem de atendimento">
                        <f:validateLength minimum="1" maximum="1"/>
                    </h:inputText>
                    
                    <b>NIS do Responsável Familiar</b>
                    <h:inputText id="nisRespFam" value="#{managedGrupoFam.nisResponsavel}" label="NIS">
                        <f:validator validatorId="validatorNis"/>
                    </h:inputText>
                </h:panelGrid>
                <br/>
                <h:commandButton value="Pesquisar"/>
                <h:commandButton value="Pesquisar Todos os grupos" onclick="disable()"/>
                <script>
                    controlaRadio();
                </script>
            </h:form>
        </ui:define>
    </ui:composition>
</html>